
/****************************************************************************/

int kernelWindowUpdate(objectKey key, int clipX, int clipY, int width, int height)
{
	int status = 0;

	if (!initialized)
		return (status = ERR_NOTINITIALIZED);

	ACQUIRE_WINDOW_LIST
		return (status = ERR_NOLOCK);

	kernelWindow *window = castKeyToWindow(key);

	if (!window)
		status = ERR_NOSUCHENTRY;
	else if (!window->_update)
		status = ERR_NOTIMPLEMENTED;
	else
		status = window->_update(window, clipX, clipY, width, height);

	RELEASE_WINDOW_LIST

	return (status);
}

/****************************************************************************/

int kernelWindowUpdateBuffer(kernelGraphicBuffer *buffer, int clipX, int clipY, int width, int height)
{
	// A component is trying to tell us that it has updated itself in the
	// supplied buffer, and would like the bounded area of the relevent window
	// to be redrawn on screen. This function finds the relevent window and
	// calls kernelWindowUpdate().

	int status = 0;
	kernelWindow *window = NULL;
	int count;

	// Check parameters
	if (buffer == NULL)
		return (status = ERR_NULLPARAMETER);

	// Lock the window list
	ACQUIRE_WINDOW_LIST
		return (status = ERR_NOLOCK);

	// First try to find the window

	for (count = 0; count < numberWindows; count ++)
	{
		if (windowList[count]->buffer == buffer)
		{
			window = windowList[count];
			break;
		}
	}

	if (window == NULL)
		status = ERR_NOSUCHENTRY;
	else
		status = kernelWindowUpdate(window, clipX, clipY, width, height);

	RELEASE_WINDOW_LIST

	return (status);
}

/****************************************************************************/

